home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------
- Expand a folder name, taking account of the folders_dir and `~'.
-
- Args: filename -- The name of the file that is the folder
-
- Result: The folder name is expanded in place.
- Returns 0 and queues status message if unsuccessful.
- Input string is overwritten with expanded name.
- Returns 1 if successful.
-
- BUG should limit length to MAXPATH
- ----*/
- int
- expand_foldername(filename)
- char *filename;
- {
- char temp_filename[MAXPATH+1];
-
- dprint(5, (debugfile, "=== expand_foldername called (%s) ===\n",filename));
-
- /*
- * We used to check for valid filename chars here if "filename"
- * didn't refer to a remote mailbox. This has been rethought
- */
-
- strcpy(temp_filename, filename);
- if(strucmp(temp_filename, "inbox") == 0) {
- strcpy(filename, ps_global->VAR_INBOX_PATH == NULL ? "inbox" :
- ps_global->VAR_INBOX_PATH);
- } else if(temp_filename[0] == '{') {
- strcpy(filename, temp_filename);
- } else if(ps_global->restricted
- && (strindex("./~", temp_filename[0]) != NULL
- || srchstr(temp_filename,"/../"))){
- q_status_message(SM_ORDER, 0, 3, "Can only open local folders");
- return(0);
- } else if(temp_filename[0] == '*') {
- strcpy(filename, temp_filename);
- } else if(ps_global->VAR_OPER_DIR && srchstr(temp_filename,"..")){
- q_status_message(SM_ORDER, 0, 3,
- "\"..\" not allowed in folder name");
- return(0);
- } else if (temp_filename[0] == '~'){
- if(fnexpand(temp_filename, sizeof(temp_filename)) == NULL) {
- char *p = strindex(temp_filename, '/');
- if(p != NULL)
- *p = '\0';
- q_status_message1(SM_ORDER, 3, 3,
- "Error expanding folder name: \"%s\" unknown user",
- temp_filename);
- return(0);
- }
- strcpy(filename, temp_filename);
- } else if(temp_filename[0] == '/') {
- strcpy(filename, temp_filename);
- } else if(F_ON(F_USE_CURRENT_DIR, ps_global)){
- strcpy(filename, temp_filename);
- } else if(ps_global->VAR_OPER_DIR){
- build_path(filename, ps_global->VAR_OPER_DIR, temp_filename);
- } else {
- build_path(filename, ps_global->home_dir, temp_filename);
- }
- dprint(5, (debugfile, "returning \"%s\"\n", filename));
- return(1);
- }
-
-
-